#include <iostream>
#include "Matrix.h"
using namespace std;

int main()
{
	int opt;
	Matrix A, B, C, R;
	A.allocate();
	B.allocate();
	R.allocate();
	int usr_inp[ORDER][ORDER];

	do
	{
		cout<<"Please select an operation:"<<endl;
		cout<<"\tPress 1 for A+B"<<endl;
		cout<<"\tPress 2 for A-B"<<endl;
		cout<<"\tPress 3 for A*B"<<endl;
		cout<<"\tPress 4 for A+B-C"<<endl;
		cout<<"\tPress 5 for (A*B)+C"<<endl;
		cout<<"\tPress 6 for (A+B)*C"<<endl;
		cout<<"\tPress 7 for (A*B)-C"<<endl;
		cout<<"\tPress 8 for (A-B)*C"<<endl;
		cout<<"\tPress 9 to exit"<<endl;
		cin>>opt;
		if(opt>0 && opt<4)
		{
			cout<<"Enter matrix A"<<endl;
			get_input(usr_inp);
			A.initialize(usr_inp);
			cout<<"Enter matrix B"<<endl;
			get_input(usr_inp);
			B.initialize(usr_inp);
		}
		else if(opt>3 && opt<9)
		{
			C.allocate();
			cout<<"Enter matrix A"<<endl;
			get_input(usr_inp);
			A.initialize(usr_inp);
			cout<<"Enter matrix B"<<endl;
			get_input(usr_inp);
			B.initialize(usr_inp);
			cout<<"Enter matrix C"<<endl;
			get_input(usr_inp);
			C.initialize(usr_inp);
		}
		switch(opt)
		{
			case 1:
				R = A.add(B);
				cout<<"Result is:"<<endl;
				R.display();
				break;
			case 2:
				R = A.subtract(B);
				cout<<"Result is:"<<endl;
				R.display();
				break;
			case 3:
				R = A.multiply(B);
				cout<<"Result is:"<<endl;
				R.display();
				break;
			case 4:
				R = A.add(B);
				R = R.subtract(C);
				cout<<"Result is:"<<endl;
				R.display();
				break;
			case 5:
				R = A.multiply(B);
				R = R.add(C);
				cout<<"Result is:"<<endl;
				R.display();
				break;
			case 6:
				R = A.add(B);
				R = R.multiply(C);
				cout<<"Result is:"<<endl;
				R.display();
				break;
			case 7:
				R = A.multiply(B);
				R = R.subtract(C);
				cout<<"Result is:"<<endl;
				R.display();
				break;
			case 8:
				R = A.subtract(B);
				R = R.multiply(C);
				cout<<"Result is:"<<endl;
				R.display();
				break;
		}
	}while(opt!=9);
	return 0;
}